<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app" @click="divClick">
        <!-- 1、修饰符,click.stop  点击div的时候，btn的点击事件不执行-->
        {{message}}
        <button @click="btnClick">按钮1</button>
    </div>

    <!-- 2、click.prevent修饰符的使用,阻止表单自动提交，通过自己写的方法提交 -->
    <form action="http://wwww.baidu.com">
        <!-- <input type="submit" value="提交" @click.prevent="submitClick"> -->
    </form>

    <!-- 3、监听某个键盘的键帽 -->
    <br><input type="text" @keyUp="keyClick()">

    <!-- 4、click.once 只触发一次 -->
    <br><button @click="onceClick()">.once测试</button>

    <script>
        var vm = new Vue({
            el: '#app',
            data: {
                message: '我是你爹!'
            },
            methods: {
                btnClick: function() {
                    console.log('点击了按钮btnClick');
                },
                divClick: function() {
                    console.log('点击了div  divClick');
                },
                submitClick: function() {
                    console.log('submitClick');
                },
                keyClick: function() {
                    console.log("测试111111111111");
                    console.log('keyUp');
                },
                onceClick() {
                    console.log('只触发一次');
                }

            }
        });
    </script>
</body>

</html>